/*
 * Copyright (C) 2012 Damien Girard <dgirard@nativesoft.fr>
 * Copyright (C) 2012 Sebastien Baudrand <sebbaudrand@gmail.com>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package fr.umlv.qroxy.communication.transfer;

/**
 * Result of a transfer operation.
 *
 * @author Damien Girard <dgirard@nativesoft.fr>
 * @author Sebastien Baudrand <sebbaudrand@gmail.com>
 */
public class TransferResult {

    private final int count;
    private final boolean finished;
    private final boolean moreDataToWrite;

    public TransferResult(int count, boolean finished) {
        this.finished = finished;
        this.count = count;
        this.moreDataToWrite = false;
    }

    public TransferResult(int count, boolean finished, boolean moreDataToWrite) {
        this.count = count;
        this.finished = finished;
        this.moreDataToWrite = moreDataToWrite;
    }

    /**
     * Number of bytes read or write.
     *
     * @return Number of bytes.
     */
    public int getCount() {
        return count;
    }

    /**
     * Does the transfer operation is finished?
     *
     * @return True if transfer of all data has been made.
     */
    public boolean isFinished() {
        return finished;
    }

    /**
     * Does there is more data to be write?
     *
     * @return True if there is more data to be write.
     */
    public boolean hasMoreDataToWrite() {
        if (finished) { // If I have finished the write operation, there is no more data to write.
            return false;
        }
        return moreDataToWrite;
    }
}
